package im.oen.gui.tools.component;

import im.oen.boot.common.utils.Checker;
import im.oen.gui.tools.data.connect.AbsConnect;

import javax.swing.tree.DefaultMutableTreeNode;

/**
 * @author Kevin.Xu
 */
public class JTreeNode extends DefaultMutableTreeNode {

    private JTreeNode parentNode;
    private Object obj;

    public JTreeNode(Object obj) {
        super(obj);
        this.obj = obj;
    }

    public void add(JTreeNode node) {
        if (Checker.isEmpty(node)) {
            return;
        }

        super.add(node);
        node.setParentNode(this);
    }

    public Object getObj() {
        return obj;
    }

    public <T> T getData() {
        return (T) obj;
    }

    public JTreeNode getParentNode() {
        return parentNode;
    }

    public void setParentNode(JTreeNode parentNode) {
        this.parentNode = parentNode;
    }

    public boolean isAbsConnect() {
        return this.obj instanceof AbsConnect;
    }
}
